package com.doudou.oauth.util;

import com.doudou.commons.entity.Result;
import com.fasterxml.jackson.databind.ObjectMapper;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Author: 傻男人
 * @Date: 2020/5/15 13:30
 * @Version: 1.0
 * @Description: 写错误信息
 */
public class HttpUtils {

    public static void writerError(Result result, HttpServletResponse response) throws IOException {
        response.setContentType("application/json,charset=utf-8");
        response.setStatus(result.getCode());
        ObjectMapper objectMapper = new ObjectMapper();
        objectMapper.writeValue(response.getOutputStream(),result);
    }

}